package com.chuangfeng.building.ms.login.service.impl;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chuangfeng.building.common.CoreMngImpl;
import com.chuangfeng.building.entity.TAdminInfo;
import com.chuangfeng.building.ms.login.dao.AdminDao;
import com.chuangfeng.building.ms.login.service.AdminMng;
import com.chuangfeng.framework.core.exception.ServiceException;

@Service
public class AdminMngImpl extends CoreMngImpl<TAdminInfo> implements AdminMng {

	private final Logger logger = Logger.getLogger(this.getClass());

	private AdminDao adminDao;

	public AdminDao getAdminDao() {
		return adminDao;
	}

	@Autowired
	public void setAdminDao(AdminDao adminDao) {
		super.setDao(adminDao);
		this.adminDao = adminDao;
	}

	/**
	 * 管理员登入验证
	 */
	public TAdminInfo checkAdmin(String userName, String password) {
		try{
			 return adminDao.checkAdmin(userName, password);
		}catch(Exception e){
			logger.error("管理员登入失败："+e.getMessage());
			throw new ServiceException(e.getMessage());
		}
	}

}
